
package com.forestar.mapControl.utils.mapConvert.geometry;

import android.graphics.Point;

import com.forestar.mapControl.utils.mapConvert.geometry.coordinatesystem.CoordinateSystem;
import com.mapzone.api.geometry.mzPoint;


public class GeoPoint implements IGeometry
{
    private CoordinateSystem coordSystem;
    private double x;
    private double y;
    private Point point;
    private Envelope envelope;
    private mzPoint m_mzPoint;

    public GeoPoint(CoordinateSystem coordSystem, double x, double y)
    {
        this.coordSystem = coordSystem;
        this.x = x;
        this.y = y;
    }

    public GeoPoint(CoordinateSystem coordSystem, mzPoint geo)
    {
        this.coordSystem = coordSystem;
//        this.x = geo.getX();
//        this.y = geo.getY();
        this.m_mzPoint = geo;
    }

    public GeoPoint(CoordinateSystem coordSystem, Point gm)
    {
        this.point = gm;
//        Position ps = gm.getPosition();
//        if (ps == null)
//        {
//            ps = new Position(0, 0);
//        }
//        this.coordSystem = coordSystem;
//        this.x = ps.getLongitude();
//        this.y = ps.getLatitude();
    }

    @Override
    public GeoPoint clone()
    {
        GeoPoint geoPoint = new GeoPoint(this.coordSystem, x, y);
        return geoPoint;
    }

    public CoordinateSystem getCoordinateSystem()
    {
        return coordSystem;
    }

    @Override
    public void setCoordinateSystem(CoordinateSystem coordSystem)
    {
        this.coordSystem = coordSystem;
    }
    
    public void setXY(double x,double y)
    {
    	this.x = x;
    	this.y = y;
    }

    public void setX(double x)
    {
        this.x = x;
    }

    public void setY(double y)
    {
        this.y = y;
    }

    public double getX()
    {
        return x;
    }

    public double getY()
    {
        return y;
    }

    @Override
    public GeometryType getGeometryType()
    {
        return GeometryType.GeometryTypePoint;
    }

    @Override
    public Envelope getEnvelope()
    {
        return new Envelope(this.coordSystem, this.x, this.x, this.y, this.y);
    }

    @Override
    public  IGeometry Clone()
    {
        mzPoint m_mzPointClone = (mzPoint) this.m_mzPoint.clone();
        GeoPoint geoPoint = new GeoPoint(this.coordSystem, m_mzPointClone);
        return  geoPoint;
    }

    @Override
    public byte[] getBlob()
    {
        return GeoConverter.Geom2Blob(this.m_mzPoint);
    }

    @Override
    public Object getInternalObject() {
        return m_mzPoint;
    }

    @Override
    public boolean isSimple()
        {
            return true;
        }
}
